package com.oracle.lingshangejia.adapter;

import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lws.basic.utils.common.MyLogger;
import com.oracle.lingshangejia.R;
import com.oracle.lingshangejia.bean.VisitRecordBean;

import java.util.List;

/**
 * @松 on 2019/10/31 12:55
 * 随访记录
 */
public class VisitRecodeAdapter extends BaseQuickAdapter<VisitRecordBean.DataBean.RowsBean, BaseViewHolder> {

    public VisitRecodeAdapter( @Nullable List<VisitRecordBean.DataBean.RowsBean> data) {
        super(R.layout.item_visit_record, data);
    }

    @Override
    protected void convert(BaseViewHolder helper,VisitRecordBean.DataBean.RowsBean item) {
                helper.setText(R.id.tv_name, "患者：" + item.getJmName());
                helper.setText(R.id.tv_time, "随访时间：" + item.getNextSfDate());
                helper.setText(R.id.tv_content, "服务项目：" + item.getZxName());
                ConstraintLayout cl = helper.getView(R.id.cl);
                CheckBox checkBox = helper.getView(R.id.cb);
                TextView tv = helper.getView(R.id.tv_resident);
                helper.addOnClickListener(R.id.cb);
                if (item.isIs()) {
                    checkBox.setChecked(false);
                } else {
                    checkBox.setChecked(false);
                }

                if (item.getAppPushState() == 0) {//0未下发  1已下发
                    checkBox.setVisibility(View.VISIBLE);
                    tv.setVisibility(View.INVISIBLE);
                    cl.setBackgroundResource(R.drawable.corners6_s1_t_bule);//蓝色未下发
                    helper.setText(R.id.tv_state, "app通知：未发送");
                } else /*(item.getAppPushState() == 1)*/ {
                    checkBox.setVisibility(View.INVISIBLE);
                    tv.setVisibility(View.VISIBLE);
                    switch (item.getAppPushCallback()) {
                        case 0:
                            tv.setText("居民状态：未确认");
                            break;
                        case 1:
                            tv.setText("居民状态：已延期");
                            break;
                        case 2:
                            tv.setText("居民状态：已同意");
                            break;
                    }
                    helper.setText(R.id.tv_state, "app通知：已发送");
                    cl.setBackgroundResource(R.drawable.corners6_s1_t_green);  //绿色已下发
                }
                switch (item.getSfResult()) {
                    case 0://未发app通知
                        break;
                    case 1://app通知未确认
                        break;
                    case 2://短信未确认
                        break;
                    case 3://语音未确认
                        break;
                    case 4://已拒绝
                        break;
                    case 5://已同意
                        break;
                    case 6://延期
                        break;
                    case 7://已随访
                        helper.setText(R.id.tv_state, "已随访");
                        tv.setVisibility(View.INVISIBLE);
                        cl.setBackgroundResource(R.drawable.corners6_s1_t_999999);
                        break;

                }
    }


}
